package com.ruoyi.project.system.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MiddleTableData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.mapper.TRightorwrongMapper;
import com.ruoyi.project.system.domain.TRightorwrong;
import com.ruoyi.project.system.service.ITRightorwrongService;

/**
 * 判断题库Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@Service
public class TRightorwrongServiceImpl implements ITRightorwrongService 
{
    @Autowired
    private TRightorwrongMapper tRightorwrongMapper;

    /**
     * 查询判断题库
     * 
     * @param rightorwrongId 判断题库ID
     * @return 判断题库
     */
    @Override
    public TRightorwrong selectTRightorwrongById(Integer rightorwrongId)
    {
        return tRightorwrongMapper.selectTRightorwrongById(rightorwrongId);
    }

    /**
     * 查询判断题库列表
     * 
     * @param tRightorwrong 判断题库
     * @return 判断题库
     */
    @Override
    public List<TRightorwrong> selectTRightorwrongList(TRightorwrong tRightorwrong)
    {
        return tRightorwrongMapper.selectTRightorwrongList(tRightorwrong);
    }

    /**
     * 新增判断题库
     * 
     * @param tRightorwrong 判断题库
     * @return 结果
     */
    @Override
    public int insertTRightorwrong(TRightorwrong tRightorwrong)
    {
        tRightorwrong.setCreateTime(DateUtils.getNowDate());
        return tRightorwrongMapper.insertTRightorwrong(tRightorwrong);
    }

    /**
     * 修改判断题库
     * 
     * @param tRightorwrong 判断题库
     * @return 结果
     */
    @Override
    public int updateTRightorwrong(TRightorwrong tRightorwrong)
    {
        return tRightorwrongMapper.updateTRightorwrong(tRightorwrong);
    }

    /**
     * 批量删除判断题库
     * 
     * @param rightorwrongIds 需要删除的判断题库ID
     * @return 结果
     */
    @Override
    public int deleteTRightorwrongByIds(Integer[] rightorwrongIds)
    {
        deleteMiddle(rightorwrongIds[1],rightorwrongIds[0]);
        return tRightorwrongMapper.deleteTRightorwrongByIds(rightorwrongIds);
    }

    /**
     * 删除判断题库信息
     * 
     * @param rightorwrongId 判断题库ID
     * @return 结果
     */
    @Override
    public int deleteTRightorwrongById(Integer rightorwrongId)
    {
        return tRightorwrongMapper.deleteTRightorwrongById(rightorwrongId);
    }

    @Override
    public int addMiddle(Integer  subject_id ,Integer multiSel_id) {
        MiddleTableData middleTableData = new MiddleTableData();
        return tRightorwrongMapper.addMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }

    @Override
    public int updateMiddle(Integer  subject_id ,Integer multiSel_id,String courseName) {
        MiddleTableData middleTableData = new MiddleTableData();
        Map map = middleTableData.FZMap(subject_id, multiSel_id);
        map.put("courseName",courseName);
        return tRightorwrongMapper.updateMiddle(map);
    }

    @Override
    public int deleteMiddle(Integer  subject_id ,Integer multiSel_id) {

        MiddleTableData middleTableData = new MiddleTableData();
        return tRightorwrongMapper.deleteMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }
}
